<?php use_helper('LetsManager','Phone','Url') ?>

<h2><?php echo $title ?></h2>

<table class="datalist">
  <thead>
    <tr>
      <th><?php echo link_to('Id', '@lets_members_list?orderby=username&query='.$queryForUrl) ?></th>
      <th><?php echo link_to('Nom',    '@lets_members_list?orderby=firstname&query='.$queryForUrl) ?></th>
      <th><?php echo link_to('Prénom', '@lets_members_list?orderby=lastname&query='.$queryForUrl) ?></th>
      <th width="20%">Email</th>
      <th>Téléphone</th>
    </tr>
  </thead>
  <tbody>
  <?php foreach($members as $member): ?>
    <tr>
      <td><?php echo $member->getUsername() ?></td>
      <td><?php echo link_to($member->getLastname(),'@lets_user_show?id='.$member->getId(),array('popup'=>true)) ?></td>
      <td><?php echo link_to($member->getFirstname(),'@lets_user_show?id='.$member->getId(),array('popup'=>true)) ?></td>
      <td><?php echo mail_to($member->getEmail()) ?></td>
      <td><?php 
        $phone1 = format_phonenumber($member->getPhoneHome());
        $phone2 = format_phonenumber($member->getPhoneMobile());
        $str = '';
        if($phone1 != '' && $phone2 != '')
        {
          $str = $phone1.' ou '.$phone2;
        }
        else if($phone1 != '')
        {
          $str = $phone1;
        }
        else
        {
          $str = $phone2;
        }
        echo $str;
        ?></td>
    </tr>
  <?php endforeach ?>
  <?php if(count($members) == 0): ?>
    <tr><td colspan="5">Aucun résultat</td></tr>  
  <?php endif ?>
  </tbody>
</table>
<br/>
<?php echo link_to('Annuaire en PDF','@lets_members_export_pdf',array('class'=>'button blue','popup'=>true)) ?>
